CREATE OR REPLACE EDITIONABLE PACKAGE "SCOTT"."PKG_STOCK_TRANSACTION_DATA" 
IS
  -- 计算简单移动平均线
  PROCEDURE CALCULATE_FIVE;
  PROCEDURE CALCULATE_TEN;
  PROCEDURE CALCULATE_TWENTY;
  PROCEDURE CALCULATE_SIXTY;
  PROCEDURE CALCULATE_ONEHUNDREDTWENTY;
  PROCEDURE CALCULATE_TWOHUNDREDFIFTY;
  --PROCEDURE CALCULATE_INFINITE;
  -- 插入股票记录
  -- 这个存储过程不再使用了
  PROCEDURE WRITE_STOCK_TRANSACTION_DATA(
      p_date                     IN DATE,
      p_code                     IN VARCHAR2,
      p_open_price               IN NUMBER,
      p_close_price              IN NUMBER,
      p_highest_price            IN NUMBER,
      p_lowest_price             IN NUMBER,
      p_change_amount            IN NUMBER,
      p_change_range             IN NUMBER,
      p_turnover_rate            IN NUMBER,
      p_volume                   IN NUMBER,
      p_turnover                 IN NUMBER,
      p_total_market_value       IN NUMBER,
      p_circulation_market_value IN NUMBER);
  -- 计算某一天所有股票的简单移动平均线
  PROCEDURE WRITE_MOVING_AVERAGE_BY_DATE(
      p_date IN VARCHAR2);
  -- 计算某一日有哪些股票处于多头排列
  PROCEDURE SELECT_BULL_RANK_STOCK(
      p_date IN VARCHAR2,
      p_num OUT NUMBER);
TYPE MYCURSOR
IS
  REF
  CURSOR;
    PROCEDURE TEST(
        stockDate IN VARCHAR2);
    -- 选择股票
    PROCEDURE SELECT_REVERSE_STOCK(
        p_date       IN VARCHAR2,
        p_percentage IN NUMBER,
        p_result_stock_code OUT T_TYPE_ARRAY);
    /*procedure SELECT_STOCK_3(stockDate in varchar2,percentage in number);*/
    /*procedure SELECT_STOCK_WITH_250_SUPPORT(p_date        in varchar2,
    p_near_rate      in number,
    p_down_rate         in number,
    p_stock_result_array out T_STOCK_RESULT_ARRAY);*/
    PROCEDURE SELECT_STOCK_WITH_120_SUPPORT(
        p_date      IN VARCHAR2,
        p_near_rate IN NUMBER,
        p_down_rate IN NUMBER,
        p_stock_result_array OUT T_STOCK_RESULT_ARRAY);
    PROCEDURE SELECT_STOCK_WITH_250_SUPPORT(
        p_date      IN VARCHAR2,
        p_near_rate IN NUMBER,
        p_down_rate IN NUMBER,
        p_stock_result_array OUT T_STOCK_RESULT_ARRAY);
    PROCEDURE SELECT_MACD_UP_BELOW_ZERO(
        p_date IN VARCHAR2,
        p_rate IN NUMBER,
        p_stock_macd_result OUT T_TYPE_ARRAY);
    PROCEDURE SELECT_MACD_GOLD_CROSS(
        p_date IN VARCHAR2,
        p_rate IN NUMBER,
        p_stock_macd_result OUT T_TYPE_ARRAY);
    -- 计算所有股票当天的收盘价是否大于前一天的收盘价
    -- stock_transaction_data表的up_down字段已经在获取数据时就计算好了，所以现在这个方法用不着了
    PROCEDURE WRITE_UP_DOWN;
    PROCEDURE WRITE_UP_DOWN_BY_DATE(
        stockDate IN VARCHAR2);
    -- 计算MACD
    PROCEDURE WRITE_MACD_INIT;
    PROCEDURE WRITE_MACD_EMA;
    PROCEDURE WRITE_MACD_DIF;
    PROCEDURE WRITE_MACD_DEA;
    PROCEDURE WRITE_MACD_EMA_BY_DATE(
        p_date IN VARCHAR2);
    PROCEDURE WRITE_MACD_DIF_BY_DATE(
        p_date IN VARCHAR2);
    PROCEDURE WRITE_MACD_DEA_BY_DATE(
        p_date IN VARCHAR2);
    -- 计算KD
    PROCEDURE WRITE_KD_INIT;
    PROCEDURE WRITE_KD_RSV;
    PROCEDURE WRITE_KD_K;
    PROCEDURE WRITE_KD_D;
    -- 计算每日的kd
    PROCEDURE WRITE_KD_BY_DATE_RSV(
        p_date VARCHAR2);
    PROCEDURE WRITE_KD_BY_DATE_K(
        p_date VARCHAR2);
    PROCEDURE WRITE_KD_BY_DATE_D(
        p_date VARCHAR2);
    -- 计算所有股票的ha和某一日所有股票的ha
    PROCEDURE WRITE_HA;
    PROCEDURE WRITE_HA_BY_DATE(
        p_date VARCHAR2);
    -- 计算所有股票的乖离率
    PROCEDURE WRITE_BIAS;
    -- 按照日期，计算所有股票在某一日的乖离率
    PROCEDURE WRITE_BIAS_BY_DATE(
        p_date IN VARCHAR2);
    -- 计算所有股票的方差
    PROCEDURE WRITE_VARIANCE;
    -- 按照日期，计算所有股票在某一日的的方差
    PROCEDURE WRITE_VARIANCE_BY_DATE(
        p_date IN VARCHAR2);
    PROCEDURE WRITE_CHANGE_RANGE_EX_RIGHT;
    -- WRITE_CHANGE_RANGE_EX_RIGHT_BY_DATE
    PROCEDURE WRITE_C_R_E_R_BY_DATE(
        p_date IN VARCHAR2);
    /*--------------------- 计算stock_transaction_data_all表中的布林带 -----------------------*/
    PROCEDURE CAL_BOLL;
    /*------- 计算某一日stock_transaction_data_all表中的布林带，必须在计算完均线后运行 ------*/
    PROCEDURE CAL_BOLL_BY_DATE(
        p_date VARCHAR2);
    PROCEDURE CALCULATE_VOLATILITY;
    PROCEDURE CALCULATE_CORRELATION_RATE(
        stockCode IN VARCHAR2);
    PROCEDURE CAL_UP_DOWN_PERCENTAGE_BY_DATE(
        stockDate IN VARCHAR2);
    PROCEDURE CAL_VOLATILITY_BY_DATE(
        stockDate IN VARCHAR2);
    PROCEDURE FIND_ABNORMAL_STOCK(
        p_date IN VARCHAR2,
        p_rate IN NUMBER,
        p_stock_result_array OUT T_STOCK_RESULT_ARRAY);
    -- 查找某个交易日MACD最小的股票
    PROCEDURE FIND_LOWEST_MACD_STOCK(
        p_stock_date    IN VARCHAR2,
        p_stock_number  IN NUMBER,
        p_interval_date IN NUMBER,
        p_stock_result_array OUT t_stock_result_array);
    -- 查找某段时间内涨幅最大的num只股票
    PROCEDURE FIND_TOP_STOCK(
        p_begin_date IN VARCHAR2,
        p_end_date   IN VARCHAR2,
        p_number     IN NUMBER,
        p_word_limit_num NUMBER,
        stock_top_result_array OUT T_STOCK_TOP_RESULT_ARRAY);
    -- 查找某段时间内跌幅最大的num只股票
    PROCEDURE FIND_LAST_STOCK(
        p_begin_date IN VARCHAR2,
        p_end_date   IN VARCHAR2,
        p_number     IN NUMBER,
        stock_last_result_array OUT T_STOCK_LAST_RESULT_ARRAY);
    -- 查找波段操作的股票
    PROCEDURE FIND_BOND_OPERATION_STOCK(
        p_date          IN VARCHAR2,
        p_stock_result_array OUT t_stock_result_array);
    -- 查找反包股票
    PROCEDURE FIND_TURN_UP_STOCK(p_date in varchar2/*,
        p_stock_result_array OUT t_stock_result_array*/);
  END pkg_stock_transaction_data;
